#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from sklearn.preprocessing import normalize
import numpy as np

# 载入数据
A = np.loadtxt('rs.user_rating.csv', delimiter=',')
# 按行单位化
B = normalize(A, norm='l2', axis=1)
# 求协方差
C = B @ B.transpose()
# 保存数据
np.savetxt('covmat.csv', C)
